
package models.spider.parser;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import models.aaa.Asset;
import models.spider.ISpider;
import models.spider.request.Request;

/**
 * 
 * @see tika
 * @author laurent@opprecht.info
 */
public class Parser implements IParser {

    protected List<IParser> parsers = new ArrayList<IParser>();

    public Parser() {
        ;
    }

    public Parser(final List<IParser> parsers) {
        this.parsers.addAll(parsers);
    }

    public Parser(final IParser... parsers) {
        this.parsers.addAll(Arrays.asList(parsers));
    }

    @Override
    public List<Asset> parse(final Request request, final ISpider spider) {
        for (IParser parser : parsers) {
            List<Asset> result = parser.parse(request, spider);
            if (result != null) {
                return result;
            }
        }
        return new ArrayList<Asset>();
    }
}
